/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dawnland02.model.action.controller;

import dawnland02.data.map.model.MatrixDirection;
import dawnland02.model.action.ActionFactory;
import dawnland02.model.action.ActionParam;
import dawnland02.model.entity.EntityInternal;
import dawnland02.model.task.Task;

/**
 * @author Petru Obreja (obrejap@yahoo.com)
 */
public class RotateActionController extends AbstractActionController{
    private MatrixDirection direction;

    public RotateActionController(EntityInternal entity, Task task, MatrixDirection direction) {
        super(entity, task);
        this.direction = direction;
        init();
    }

    @Override
    public void init() {
        action = ActionFactory.createDirectionAction(direction);
        action.setActionController(this);
        initialized = true;
    }

    @Override
    public void act() {
        switch(action.getCurrentStep()){
            case ACTION_BEFORE_START:{
                break;
            }
            case ACTION_INTERMEDIATE: {
                entity.setDirection((MatrixDirection)action.getValueForActionParam(ActionParam.ROTATE_DIRECTION));
                break;
            }
            case ACTION_AFTER_END: {
                this.end();
                break;
            }
        }
    }

}
